import * as index from '@/api/index.js'
export default {
	data() {
		return {
			tabsList: [{
					title: '全部订单',
					status: ''
				},
				{
					title: '进行中订单',
					status: 1
				},

				{
					title: '已完成订单',
					status: 2
				}
			],
			tabsIndex: 0,
			list: [],
			form: {
				status: '',
				page: 1
			},
			loading:false,
		}
	},

	onShow() {
		this.form.page = 1
		this.list = []
		this.getWorkerOrderList()
	},
	onLoad(option) {
	},
	onPullDownRefresh(){
		this.form.page=1
		this.list = []
		this.getWorkerOrderList()
	},
	onReachBottom(){
		this.form.page+=1
		this.getWorkerOrderList()
	},
	methods: {
		tabsChange(index) {
			if (this.tabsIndex != index) {
				this.tabsIndex = index
				this.form.status = this.tabsList[this.tabsIndex].status
				this.form.page = 1
				this.list = []
				this.getWorkerOrderList()
			}
		},
		getWorkerOrderList() {
			this.loading = false
			index.getWorkerOrderList(this.form).then(res => {
				this.loading = true
				this.list.push(...res.data.data)
			})
		},
		jump(item){
			this.$tools.navigate('/pages/user/jsOrder/jsorderDetail/index?id='+item.id)
		},
		workTime(time) {
			let date = new Date(time * 1000);
			let year = date.getFullYear();
			// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
			let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
			let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
			let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
			let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
			// let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
			// 拼接
			// return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
			return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
		}
	}
}